﻿<?php
if (isset($_GET['id_article'])) 
{

	$sql = "SELECT *  FROM user_login INNER JOIN st_article  WHERE id_article ='".$_GET['id_article']."' 
	AND intervention.id_user = user_login.id_login" ;
	$obj = new Mysql ();
	$result = mysql_query($sql);
	$row = mysql_fetch_object($result);

} else {

	$sql = "SELECT * FROM `st_article` ORDER BY date ASC ";
	$obj = new Mysql ();
	$result = mysql_query($sql);
}
// GET fournisseur
function getFournisseur($id){
	$sql = "SELECT * FROM st_att_fournisseur WHERE id_fournisseur=".$id;
	$obj = new Mysql();
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
	if($num < 1){
		$fournisseur = "aucun";
	}else{
		$fournisseur = $row['nom_fournisseur']." ".$row['prenom_fournisseur'];
	}
	return $fournisseur;
}
// GET Type Article
function getTypeArticle($id){
	$sql = "SELECT * FROM st_att_type_article WHERE id_type=".$id;
	$obj = new Mysql();
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
	if($num < 1){
		$type_article = "AUCUN";
	}else{
		$type_article = $row['nom_type'];
	}
	return $type_article;
}
// GET Lieu
function getLieu($id){
	$sql = "SELECT * FROM st_att_lieu_article WHERE id_lieu=".$id;
	$obj = new Mysql();
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
	if($num < 1){
		$lieu = "AUCUN";
	}else{
		$lieu = $row['nom_lieu'];
	}
	return $lieu;
}
// GET Unit
function getUnit($id){
	$sql = "SELECT * FROM st_att_unite_stockage WHERE id_unite_stockage=".$id;
	$obj = new Mysql();
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
	if($num < 1){
		$unit = "AUCUN";
	}else{
		$unit = $row['valeur'];
	}
	return $unit;
}
// GET Unit
function getTypemonnaie($id){
	$sql = "SELECT * FROM st_att_monnaie WHERE id_monnaie=".$id;
	$obj = new Mysql();
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
	if($num < 1){
		$type = "AUCUN";
	}else{
		$type = $row['nom_monnaie'];
	}
	return $type;
}
// GET User
function getUser($id){
	$sql = "SELECT * FROM user_login WHERE id_login=".$id;
	$obj = new Mysql();
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
	if($num < 1){
		$email = "AUCUN";
	}else{
		$email = $row['email_login'];
	}
	return $email;
}

?>